Skip to content

fix(core): include term description for flat taxonomies in getTaxonomyTerms()#1420

Merged
ascorbic merged 2 commits into
emdash-cms:mainfrom
swissky:fix/flat-taxonomy-term-description
Jun 12, 2026
Merged

fix(core): include term description for flat taxonomies in getTaxonomyTerms()#1420
ascorbic merged 2 commits into
emdash-cms:mainfrom
swissky:fix/flat-taxonomy-term-description

Conversation

@swissky

@swissky swissky commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

getTaxonomyTerms() already fetches the data column (selectAll()), but the non-hierarchical branch dropped it when mapping rows to TaxonomyTerm — only hierarchical taxonomies (via buildTree) parsed description out of it. Descriptions set in the admin UI were silently undefined for flat taxonomies.

This adds the same one-line mapping the hierarchical path uses, plus a unit test covering both kinds of taxonomies (the flat case fails without the fix).

Context: we attach knowledge-graph links (e.g. wikidata:Q380274) to term descriptions and render them as sameAs in JSON-LD; flat taxonomies (tags, treatments) lost them.

Closes #1419

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes (packages/core; @emdash-cms/admin/marketplace builds fail on my machine on unrelated tooling, untouched by this PR)
  • pnpm lint passes (lint:quick clean)
  • pnpm test passes (targeted: packages/core/tests/unit/taxonomies/ — 4 files, 48 tests green; new test red without the fix)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (n/a — no UI strings)
  • I have added a changeset (emdash patch)
  • New features link to an approved Discussion (n/a — bug fix)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Cursor + Fable 5 (reviewed and verified by a human before submission)

Screenshots / test output

RUN  v4.1.5 packages/core
✓ tests/unit/taxonomies/get-taxonomy-terms.test.ts (2 tests) — with fix
✗ 1 failed (flat-taxonomy description) — without fix (TDD check)
Test Files  4 passed (4)   Tests  48 passed (48)   # full unit/taxonomies folder

…yTerms()

The non-hierarchical branch dropped the already-fetched data column when
mapping rows to TaxonomyTerm; only buildTree (hierarchical) parsed it.

Closes emdash-cms#1419
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions github-actions Bot added review/needs-review No maintainer or bot review yet area/core size/M labels Jun 12, 2026
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f5f1087

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@swissky

swissky commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jun 12, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clean, well-scoped bug fix. The approach is sound: getTaxonomyTerms() already fetched the data column, and the PR simply adds the same description extraction that the hierarchical branch (buildTree) and getTerm already used. The flat-taxonomy branch was the only place silently dropping it.

I checked:

  • The one-line fix matches the existing pattern elsewhere in the module.
  • The new unit test covers both flat and hierarchical taxonomies (the PR author verified the flat case fails without the fix).
  • Locale filtering is unchanged and correct.
  • A changeset is present and well-written.
  • No SQL, auth, API route, or admin UI changes, so AGENTS.md conventions around those areas don't apply.

One suggestion: getEntryTerms in the same module also selects data via selectAll("taxonomies") but drops description when mapping rows. It's the exact same bug pattern, so it's worth a quick follow-up if entry-level term rendering also needs descriptions.

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-review No maintainer or bot review yet labels Jun 12, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1420

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1420

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1420

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1420

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1420

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1420

emdash

npm i https://pkg.pr.new/emdash@1420

create-emdash

npm i https://pkg.pr.new/create-emdash@1420

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1420

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1420

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1420

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1420

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1420

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1420

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1420

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1420

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1420

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1420

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1420

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1420

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1420

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1420

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1420

commit: f5f1087

@ascorbic ascorbic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ascorbic ascorbic merged commit c63f9ca into emdash-cms:main Jun 12, 2026
43 checks passed
@emdashbot emdashbot Bot mentioned this pull request Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core cla: signed review/awaiting-author Reviewed; waiting on the author to respond size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getTaxonomyTerms() drops term description for flat (non-hierarchical) taxonomies

2 participants